<!--
 * @Descripttion: 过滤器V2
 * @version: 2.2
 * @Author: sakuya
 * @Date: 2021年7月30日14:48:41
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-09-13 16:51:46
-->

<template>
  <div class="EditSelf">
    <skVxeFilterList v-model="defaultValue" :placeholder="placeholder" :multiple="option.multiple" :params="params"
      :filterparams="filterparams" :renderOpts="renderOpts" />
  </div>
</template>
<script>
// import config from "@/config/filterBar";
import skVxeFilterList from "@/components/skVxeFilterList";
import XEUtils from "xe-utils";
export default {
  name: "filterBar",

  props: {
    params: Object,
    modelValue: Object,
    renderOpts: Object,
  },
  components: { skVxeFilterList },
  data() {
    const { row, column } = this.params;
    return {
      defaultValue: XEUtils.get(row, column.field),
      option: "",
      placeholder: column.editRender.attrs.placeholder,
      filterparams: eval(this.renderOpts.attrs.filterparams),
    };
  },
  mounted() {
    // const { row, column } = this.params;
    // let attr = column.editRender.attrs;
    // //对于select的情况下，有默认赋值，通过key 取value
    // if (attr.filterfield && attr.editfilter == 'select') {
    //   this.defaultValue = XEUtils.get(row, attr.filterfield);
    // }
    // this.defaultValue = ;
  },
  watch: {
    defaultValue: {
      handler(val) {
        const { row, column } = this.params;
        XEUtils.set(row, column.field, val);
        this.params.$grid.updateFooter();
        this.$emit("update:modelValue", val);
      },
      deep: true,
    },
  },
  computed: {},

  methods: {},
};
</script>
<style scope>
.EditSelf {
  padding: 0;
  height: 24px;
}

.EditSelf input {
  font-size: 12px;
  height: 24px;
}
</style>
